home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming All in One / 3D Game Programming All in One Disc.iso / 3D2E / RESOURCES / CH2 / WhilingAway.cs < prev    next >
Text File  |  2006-05-29  |  855b  |  22 lines

  1. // ========================================================================
  2. //  WhilingAway.cs
  3. //
  4. //  This module is a program that demonstrates while loops. It prints
  5. //  random values on the screen as long as a condition is satisfied.
  6. //
  7. // ========================================================================
  8.  
  9. function runWhilingAway()
  10. // ----------------------------------------------------
  11. //     Entry point for the program.
  12. // ----------------------------------------------------
  13. {
  14.    %value = 0;            // initialize %value
  15.    while (%value < 7)     // stop looping if %n exceeds 7
  16.    {
  17.       %value = GetRandom(10); // get a random number between 0 and 10
  18.       echo("value="@%value);     // print the result
  19.    }                      // back to the top of the loop
  20.                           // ie. do it all again
  21. }
  22.